package com.bruce.aidemo.service;

import com.alibaba.cloud.ai.tongyi.image.TongYiImagesClient;
import org.springframework.ai.image.ImagePrompt;
import org.springframework.ai.image.ImageResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ImageRecognitionService {

    @Autowired
    private TongYiImagesClient tongyiImageClient;

    public String recognizeImage(String imageUrl) {
        ImagePrompt imagePrompt = new ImagePrompt(imageUrl);
        ImageResponse response = tongyiImageClient.call(imagePrompt);
        return response.getResult().toString();
    }
}
